<h4 class="h4">试题列表
    <a class="btn btn-success" sid="<?=$value['id']?>"
        href="addquestions.php?sid=<?=$id?>">&nbsp;增加试题</a>
</h4>
<table class="table table-bordered">
    <tr class="success ">
        <th width="8%">ID</th>
        <th width="8%">课程名称</th>
        <th width="8%">试题类型</th>
        <th width="20%">题干</th>
        <th width="8%">答案</th>
        <th width="8%">难度</th>
        <th width="8%">考点</th>
        <th width="10%">加入时间</th>
        <th width="30%">操作</th>
    </tr>
    <?php
                    foreach ($rows as $value) {
                ?>
    <tr>
        <td><?=$value['id']?></td>
        <td><?=$value['cname']?></td>
        <td><?=$value['type']?></td>
        <td><?=$value['stem']?></td>
        <td><?=$value['resourcesinfo']?></td>
        <td><?=$value['difficulty']?></td>
        <td><?=$value['points']?></td>
        <td><?=$value['addtime']?></td>

        <td><a class="btn btn-primary examination" sid="<?=$value['id']?>">&nbsp;删除</a>
            <a class="btn btn-success" sid="<?=$value['id']?>"
                href="questionsedit.php?id=<?=$value['id']?>&sid=<?=$id?>">&nbsp;修改</a>

        </td>

    </tr>
    <?php }?>
</table>
<script>
    $('.examination').on('click', function (e) {
        layer.confirm('真的删除该试题吗？', function (index) {
            var ii = layer.load(1);
            $.ajax({
                type: 'GET',
                url: 'comm/delquestions.php?id=' + $(e.target).attr('sid'),
                dataType: 'json',
                // async: false,
                success: function (msg) {
                    if (msg.code == 200) {
                        layer.close(ii);
                        layer.close(index);
                        layer.msg('删除成功!', { icon: 1, time: 1000 });
                    } else {
                        layer.close(ii);
                        layer.close(index);
                        layer.msg('程序异常!', { icon: 5, time: 1000 });
                    }
                    window.parent.location.reload(); //刷新父页面
                },
                error: function (msg) {
                    layer.msg('程序异常!', { icon: 5, time: 1000 });
                    layer.close(index);
                }
            });
        });
    })

</script>